1 00:00:00,480 --> 00:00:03,540 Today, I'm going to show you something called the Binder Bull event. 2 00:00:03,540 --> 00:00:09,600 And it's a way you can send information from one script to another if they're of the same type. 3 00:00:09,600 --> 00:00:16,320 So a server script to a server script, local script to a local script, and we'll go through the client 4 00:00:16,320 --> 00:00:20,640 server stuff when we do remote events, which is coming up soon. 5 00:00:22,300 --> 00:00:30,220 I'm going to demonstrate binding events by sending a message from my wave loop to my lava script, make 6 00:00:30,220 --> 00:00:31,780 an eruption go off. 7 00:00:31,780 --> 00:00:34,900 So it's going to be a server thing to a server thing, right? 8 00:00:34,900 --> 00:00:36,490 Both are server scripts. 9 00:00:36,490 --> 00:00:41,500 I'm going to go to server storage because this is going to be an event that's happening on the server 10 00:00:41,500 --> 00:00:42,220 side. 11 00:00:42,310 --> 00:00:48,610 I'm going to go to plus right here, hit a B for findable event and add it. 12 00:00:48,610 --> 00:00:50,380 It doesn't have to be in server storage. 13 00:00:50,380 --> 00:00:54,610 It could be in the workspace, but I'm going to put it here so I don't forget where it's at. 14 00:00:54,760 --> 00:01:01,630 I'm going to call this lava B for lava bind double event. 15 00:01:03,330 --> 00:01:09,600 Now I'm going to open up my wave loop, go to server script service, wave loop, and I'm going to get 16 00:01:09,600 --> 00:01:11,480 access to my BIND event. 17 00:01:11,490 --> 00:01:14,970 I put it in server storage, so I'm going to need a variable for that. 18 00:01:15,180 --> 00:01:22,290 I'll call that s for server storage game, get service server storage. 19 00:01:22,290 --> 00:01:30,330 And in there we have our bind able event and we call that larva B, I'll call the variable larva B but 20 00:01:30,330 --> 00:01:38,880 with a lowercase L, that's just my convention and we'll get our server server storage variable, wait 21 00:01:38,880 --> 00:01:45,000 for a child and then larva B make sure you see it in there. 22 00:01:45,600 --> 00:01:45,870 All right. 23 00:01:45,870 --> 00:01:49,740 Another variable I'm going to use is a wave loop counter. 24 00:01:49,740 --> 00:01:56,790 So I'm just going to do local wave loop equals zero. 25 00:01:58,460 --> 00:02:04,490 Let's go ahead and scroll down to the bottom of our while loop underneath the spawn zombies. 26 00:02:04,700 --> 00:02:07,520 I'll do a little wait right here, maybe a second. 27 00:02:07,520 --> 00:02:16,550 Just to slow down my loop and then I'm going to fire my bull event, my lava B, I'll do lava B colon 28 00:02:16,760 --> 00:02:17,630 fire. 29 00:02:17,660 --> 00:02:19,540 That's going to fire the event off. 30 00:02:19,550 --> 00:02:21,980 We'll be able to pick that up in our lava script. 31 00:02:22,010 --> 00:02:23,270 I'm going to show you in a minute. 32 00:02:23,270 --> 00:02:29,810 But just to make it interesting, I'm going to send two values with my bondable event so you can see 33 00:02:29,810 --> 00:02:31,280 how to transfer data. 34 00:02:31,400 --> 00:02:39,440 I'll send two messages, maybe lava event with an exclamation so you could see it strings going over. 35 00:02:39,590 --> 00:02:44,660 And then we're going to do our wave loop, right, just so you can see an integer going, too. 36 00:02:44,930 --> 00:02:47,960 Let's go ahead and get our wave loop. 37 00:02:48,380 --> 00:02:50,090 Do a plus equals one. 38 00:02:50,090 --> 00:02:54,080 So we're going to increment our wave loop every iteration of the loop. 39 00:02:54,110 --> 00:02:57,230 We're going to take the old wave loop and add one to it. 40 00:02:59,120 --> 00:03:02,800 Now let's go ahead and look for our lava in the workspace. 41 00:03:02,810 --> 00:03:04,260 Here's my workspace. 42 00:03:04,280 --> 00:03:05,520 Here's lava. 43 00:03:05,540 --> 00:03:09,950 I'm going to open it up and then open the eruption script. 44 00:03:10,100 --> 00:03:11,360 There we go. 45 00:03:11,510 --> 00:03:14,840 I need to get that findable event and listen to it. 46 00:03:14,840 --> 00:03:20,420 So I'm going to make a variable for server storage right here at the top. 47 00:03:20,630 --> 00:03:21,650 And I'll say. 48 00:03:22,280 --> 00:03:32,240 That's my variable convention for server storage gain colon, Get service, server storage. 49 00:03:32,420 --> 00:03:39,140 Then I'm going to get another variable for my binding event and I'm going to call Lava B because I don't 50 00:03:39,140 --> 00:03:40,490 want to get confused. 51 00:03:40,610 --> 00:03:42,770 I'm going to get that from server storage. 52 00:03:42,770 --> 00:03:46,450 I'll do a wait for child lava B. 53 00:03:47,540 --> 00:03:48,230 In this script. 54 00:03:48,230 --> 00:03:54,920 Notice that we already have our erupt function and our drain function, but down here we only call it 55 00:03:54,920 --> 00:03:55,730 one time. 56 00:03:55,730 --> 00:03:59,540 We wait 8 seconds after the game starts up, erupt. 57 00:03:59,540 --> 00:04:01,550 Wait a second drain. 58 00:04:01,550 --> 00:04:08,570 Let's wrap this in a function so that we can call it periodically with our bondable event. 59 00:04:08,570 --> 00:04:09,770 So I got rid of that. 60 00:04:09,770 --> 00:04:10,850 Wait 8 seconds. 61 00:04:10,850 --> 00:04:11,840 I don't need it. 62 00:04:11,840 --> 00:04:17,570 I'm going to do a local function activate eruption. 63 00:04:18,140 --> 00:04:21,350 I'm going to go down underneath the drain and do my end. 64 00:04:21,350 --> 00:04:24,950 I'm wrapping this in a function called Activate eruption. 65 00:04:24,950 --> 00:04:30,500 Let's go to format selection, format, document, give us some nice indents. 66 00:04:30,500 --> 00:04:32,720 And remember, we are our able event. 67 00:04:32,720 --> 00:04:34,460 We pass two parameters. 68 00:04:34,460 --> 00:04:36,530 We can capture those here. 69 00:04:36,530 --> 00:04:38,930 Let's get some variables for those parameters. 70 00:04:39,170 --> 00:04:45,770 We'll say MSG because one said something like lava vent and then a val for our integer. 71 00:04:45,770 --> 00:04:49,580 We had a wave loop coming over to and you can send more stuff than that. 72 00:04:49,580 --> 00:04:51,320 I'm just showing you how to do it. 73 00:04:51,770 --> 00:04:52,070 All right. 74 00:04:52,070 --> 00:04:56,150 So we had our lava be that was the binding event. 75 00:04:56,150 --> 00:05:01,300 We are going to listen for that event and connect to activate eruption. 76 00:05:01,310 --> 00:05:03,380 Get rid of these extra two parentheses. 77 00:05:03,380 --> 00:05:06,800 We don't need them through the magic of roadblocks. 78 00:05:06,800 --> 00:05:12,230 It's going to know to pass those variables, but let's print those variables out since we're not really 79 00:05:12,230 --> 00:05:15,710 using them, you really need to know if they're there or not. 80 00:05:15,710 --> 00:05:16,040 Right. 81 00:05:16,040 --> 00:05:23,420 So let's do a message equals MSG and then a val equals val. 82 00:05:23,420 --> 00:05:27,890 Now that we print them out, you can see that they're there and you could use that data if you wanted 83 00:05:27,890 --> 00:05:28,220 to. 84 00:05:28,250 --> 00:05:30,440 We don't need it in this example, though. 85 00:05:32,030 --> 00:05:36,980 All right, So before we test this, I'm going to go back to my wave loop and take a look at where we 86 00:05:36,980 --> 00:05:38,810 fire that findable event. 87 00:05:39,020 --> 00:05:40,310 Fire it down here. 88 00:05:40,320 --> 00:05:43,190 But we do it every loop, iteration. 89 00:05:43,190 --> 00:05:49,250 And those loops don't take very long, what, maybe 5 seconds plus a little more for some spawning. 90 00:05:49,400 --> 00:05:53,780 I want to fire this every fifth loop iteration. 91 00:05:53,780 --> 00:06:00,860 Well, I can do that because now I have a wave loop counter and I can put an F statement in here. 92 00:06:00,860 --> 00:06:12,590 I'm going to say if wave loop modulo five equals equals zero, then I'm going to fire my event. 93 00:06:13,130 --> 00:06:13,700 Right? 94 00:06:14,090 --> 00:06:25,550 So what we're doing is we are seeing if we divide wave loop by five and there's a zero remainder, then 95 00:06:25,550 --> 00:06:28,760 we're going to consider that if statement true and fire the loop. 96 00:06:28,760 --> 00:06:34,550 So it's only going to fire on zero and five and ten like that. 97 00:06:35,030 --> 00:06:36,470 Let's try it out. 98 00:06:39,080 --> 00:06:39,620 All right. 99 00:06:39,620 --> 00:06:44,390 So now let's go to the View output and we're going to check for errors. 100 00:06:45,900 --> 00:06:47,120 I will run on over. 101 00:06:47,120 --> 00:06:52,760 I'm going to get rid of that surface terrain print out that's kind of messing up my output window. 102 00:06:53,600 --> 00:06:57,320 Let's listen for our eruption and check for our message. 103 00:06:57,710 --> 00:06:58,450 Here we go. 104 00:06:58,460 --> 00:06:59,750 There's our message. 105 00:07:00,590 --> 00:07:03,980 Message Lava event value zero. 106 00:07:03,980 --> 00:07:08,240 So that was the first, the zero wavelength. 107 00:07:08,930 --> 00:07:12,020 And then it won't go again until we hit number five. 108 00:07:13,690 --> 00:07:14,680 I should pause that. 109 00:07:14,680 --> 00:07:19,150 Maybe I'll zap some zombies while we're waiting here. 110 00:07:20,590 --> 00:07:21,490 Here we go. 111 00:07:23,370 --> 00:07:24,870 And there we are. 112 00:07:24,900 --> 00:07:29,340 Message Larva Event Value five o The Zombies Getting. 113 00:07:30,310 --> 00:07:38,410 So it looks like we got a nice a nice binder bull event firing off or a lava eruption periodically.